package cn.wsalix.shop.entity;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import lombok.Data;
import lombok.EqualsAndHashCode;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import cn.anlaser.entity.SimpleEntity;
import cn.wsalix.admin.entity.SysUser;
import cn.wsalix.shop.status.ShopEnum;

@Entity
@DynamicInsert
@DynamicUpdate
@Table(name = "SHOP")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@EntityListeners({ AuditingEntityListener.class })
@Data
@EqualsAndHashCode(callSuper = false)
public class Shop extends SimpleEntity {
	/**
	 * 
	 */
	private static final long serialVersionUID = -5693397590583180551L;
	private String shortName;
	private String alias;
	private String logo;
	private String telephone;
	private String fax;
	private ShopEnum status;

	private String address;// 地址
	@Lob
	@Basic(fetch = FetchType.LAZY)
	@Column(name = "content", columnDefinition = "TEXT", nullable = true, length = 100000)
	private String content;// 产品详情

	@ManyToOne(cascade = CascadeType.MERGE, optional = true, fetch = FetchType.LAZY)
	@JoinColumn(foreignKey = @ForeignKey(name = "FK_SHOP_PRINCIPAL"), name = "PRINCIPAL_ID")
	private SysUser principal;//负责人

}